import Vue from 'vue'
import moment from 'moment'
Vue.mixin({
    data () {
        return {
            hashCode: ""
        }
    },
    methods: {
        // 计算时间
        calcTime (createTime, validDay) {
            let startTime = moment(createTime).format('YYYY-MM-DD')
            let endTime = moment(createTime).add(validDay, 'd').format('YYYY-MM-DD')
            return `${startTime}至${endTime}`
        },
        // 原生操作
        async wxOption (type, params) {
            try {
                this.$showLoading()
                let data = {
                    type: 'APP',
                    url: location.origin + location.pathname + location.search
                }
                const res = await this.$Api.mxp_api('qywx/jsdk/getConfig', 'POST', data, true)
                this.$hideLoading()
                if (res.resp_code == 0) {
                    return await this.$wxMethod.qymethods(res.datas, type, params)
                } else {
                    this.$showToast(res.resp_msg)
                }
            } catch (error) {
                this.$hideLoading()
            }
        },
        // 原生操作
        async wxOptions (type, params) {
            try {
                this.$wxMethod.qymethods({}, type, params)
            } catch (error) {
                this.$hideLoading()
            }
        },

    }
})
